package com.qsl.ssyx.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qsl.ssyx.model.sys.Ware;
import com.qsl.ssyx.sys.mapper.WareMapper;
import com.qsl.ssyx.sys.service.WareService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qsl.ssyx.vo.product.WareQueryVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 仓库表 服务实现类
 * </p>
 *
 * @author 青衫泪
 * @since 2023-08-08
 */
@Service
public class WareServiceImpl extends ServiceImpl<WareMapper, Ware> implements WareService {

    //    条件分页查询
    @Override
    public IPage<Ware> selectPage(Page<Ware> pageParam, WareQueryVo wareQueryVo) {
        LambdaQueryWrapper<Ware> lqw = new LambdaQueryWrapper<>();
        if (!StringUtils.isEmpty(wareQueryVo.getName())) {
            lqw.like(Ware::getName, wareQueryVo.getName());
        }
        lqw.orderByDesc(Ware::getId); // 倒序排序

        Page<Ware> warePage = baseMapper.selectPage(pageParam, lqw);
        return warePage;
    }
}
